import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
 roles: ['admin','editor']    control the page roles (you can set multiple roles)
 title: 'title'               the name show in sidebar and breadcrumb (recommend set)
 icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
 breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
 activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
 }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    meta: {roles: [1,2,3]},
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {roles: [1,2,3],title: "首页" ,icon: "dashboard"}
    }]
  },

  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form', roles: [1, 2, 3] }
      }
    ]
  },
  {
    path: '/studentScoreAnalysis',
    component: Layout,
    redirect: '/txy_Analysis/excel/export-excel',
    name: 'studentScoreAnalysis',
    meta: {
      title: '学生成绩预分析',icon: 'el-icon-s-help',roles:[2,3]
    },
    children: [
      {
        path: 'upload-excel',
        component: () => import('@/views/txy_Analysis/excel/upload-excel'),
        name: 'UploadExcel',
        meta: { title: '导入文件', icon: 'el-icon-s-help' ,roles:[3]}
      },
      {
        path: 'echarts',
        name: 'Echarts',
        component: () => import('@/views/txy_Analysis/studentScore/dayScore'),
        meta: { title: '平时成绩异常检测', icon: 'tree',roles:[2,3] }
      },
      {
        path: 'devEcharts',
        name: 'DevEcharts',
        component: () => import('@/views/txy_Analysis/studentScore/devScore'),
        meta: { title: '分差异常检测', icon: 'tree',roles: [2,3] }
      },
      {
        path: 'wholeEcharts',
        name: 'wholeEcharts',
        component: () => import('@/views/txy_Analysis/studentScore/wholeScore'),
        meta: { title: '整体分析', icon: 'tree',roles: [2,3] }
      },
      {
        path: 'diffClass',
        name: 'diffClass',
        component: () => import('@/views/txy_Analysis/studentScore/diffClass'),
        meta: {title: '不同班级',icon: 'tree',roles: [2,3]}
      },
      {
        path: 'diffSemester',
        name: 'diffSemester',
        component: () => import('@/views/txy_Analysis/studentScore/diffSemester'),
        meta: {title: '不同学期',icon: 'tree',roles: [2,3]}
      }
    ]
  },
  {
    path: '/studentEvaluateAnalysis',
    component: Layout,
    redirect: '/txy_Analysis/excel/upload-excel-evaluate',
    name: 'studentEvaluateAnalysis',
    meta: {
      title: '学生评教预分析',icon: 'el-icon-s-help',roles: [2,3]
    },
    children: [
      {
        path: 'upload-excel-evaluate',
        component: () => import('@/views/txy_Analysis/excel/upload-excel-evaluate'),
        name: 'UploadExcelEvaluate',
        meta: { title: '导入文件', icon: 'el-icon-s-help',roles: [3] }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/txy_Analysis/studentEvaluate/tree'),
        meta: { title: '评教数据趋势', icon: 'tree' ,roles: [2,3]}
      },
      {
        path: 'dayEvaluate',
        name: 'dayEvaluate',
        component: () => import('@/views/txy_Analysis/studentEvaluate/dayEvaluate'),
        meta: { title: '异常检测', icon: 'tree',roles: [2,3] }
      },
      {
        path: 'endEvaluate',
        name: 'endEvaluate',
        component: () => import('@/views/txy_Analysis/studentEvaluate/endEvaluate'),
        meta: { title: '评教数据情况', icon: 'tree',roles: [2,3] }
      },
      {
        path:'timeEvaluate',
        name:'timeEvaluate',
        component:() => import('@/views/txy_Analysis/studentEvaluate/timeEvaluate'),
        meta: { title: '时间评教趋势', icon: 'tree' ,roles: [2,3]}
      },
      {
        path:'diffSemester',
        name:'diffSemester',
        component:() => import('@/views/txy_Analysis/studentEvaluate/diffSemester'),
        meta: { title: '不同学期', icon: 'tree' ,roles: [2,3]}
      }

    ]
  },

  {
    path: '/supervisionEvaluateAnalysis',
    component: Layout,
    redirect: '/txy_Analysis/excel/upload-excel-evaluate-supervision',
    name: 'supervisionEvaluateAnalysis',
    meta: {
      title: '领导评价预分析',icon: 'el-icon-s-help',roles: [2,3]
    },
    children: [
      {
        path: 'upload-excel-evaluate-supervision',
        component: () => import('@/views/txy_Analysis/excel/upload-excel-evaluate-supervision'),
        name: 'UploadExcelEvaluateVision',
        meta: { title: '导入文件', icon: 'el-icon-s-help',roles: [3] }
      },
      {
        path: 'time',
        name: 'time',
        component: () => import('@/views/txy_Analysis/supervisionEvaluate/time'),
        meta: { title: '整体情况 ', icon: 'tree' ,roles: [2,3]}
      },
      {
        path:'diffSemester',
        name:'diffSemester',
        component:() => import('@/views/txy_Analysis/supervisionEvaluate/diffSemester'),
        meta: { title: '不同学期', icon: 'tree' ,roles: [2,3]}
      }
    ]
  },
  {
    path: '/competitionAnalysis',
    component: Layout,
    redirect: '/txy_Analysis/excel/upload-excel-competiton',
    name: 'competitionAnalysis',
    meta: {
      title: '竞赛成绩预分析',icon: 'el-icon-s-help',roles: [2,3]
    },
    children: [
      {
        path: 'upload-excel-competition',
        component: () => import('@/views/txy_Analysis/excel/upload-excel-competition'),
        name: 'UploadExcelEvaluateVision',
        meta: { title: '导入文件', icon: 'el-icon-s-help' ,roles: [3]}
      },
      {
        path: 'competition',
        name: 'competition',
        component: () => import('@/views/txy_Analysis/competition'),
        meta: { title: '竞赛情况', icon: 'tree',roles: [2,3] }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link', roles: [1, 2, 3] }
      }
    ]
  },
  // 学生成绩分析
  {
    path: '/grades_analysis',
    name: 'grades',
    component: Layout,
    redirect: '/grades_analysis/normality',
    meta: {
      title: '成绩分析',
      icon: 'nested',
      roles: [2, 3]
    },
    children: [
      {
        path: 'normality',
        name: 'Normality',
        component: () => import('@/views/grades_analysis/normality/index'),
        meta: { title: '正态性检验', roles: [2, 3] }
      },
      {
        path: 'discrimination',
        name: 'Discrimination',
        component: () => import('@/views/grades_analysis/discrimination/index'),
        meta: { title: '区分度分析', roles: [2, 3] }
      },
      {
        path: 'variance',
        name: 'Variance',
        component: () => import('@/views/grades_analysis/variance/index'),
        meta: { title: '差异性分析', roles: [2, 3] }
      }
    ]
  },
  // 评教数据分析
  {
    path: '/evaluation_analysis',
    name: 'evaluation',
    component: Layout,
    redirect: '/evaluation_analysis/reliability',
    meta: {
      title: '评教分析',
      icon: 'nested',
      roles: [2, 3]
    },
    children: [
      {
        path: 'reliability',
        name: 'Reliability',
        component: () => import('@/views/evaluation_analysis/reliability/index'),
        meta: { title: '信度分析', roles: [2, 3] }
      },
      {
        path: 'validity',
        name: 'Validity',
        component: () => import('@/views/evaluation_analysis/validity/index'),
        meta: { title: '效度分析', roles: [3] }
      },
      {
        path: 'item',
        name: 'Item',
        component: () => import('@/views/evaluation_analysis/item/index'),
        meta: { title: '项目分析', roles: [3] }
      },
      {
        path: 'weight',
        name: 'Weight',
        component: () => import('@/views/evaluation_analysis/weight/index'),
        meta: { title: '权重', roles: [2, 3] }
      }
    ]
  },
  // 数据关联分析子系统
  {
    path: '/correlation',
    component: Layout,
    redirect: '/correlation/rule',
    name: '关联分析',
    meta: {
      title: '关联分析',
      icon: 'nested',
      roles: [2, 3]
    },
    children: [
      {
        path: 'rule',
        name: '关联规则分析',
        component: () => import('@/views/rule/index'),
        meta: { title: '关联规则分析', icon: 'table', roles: [2, 3] },
        children: [
          {
            path: '/rule-1',
            name: '课程与课程',
            component: () => import('@/views/rule/rule-1/index'),
            meta: { title: '课程与课程', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/rule-2',
            name: '课程与学生评教',
            component: () => import('@/views/rule/rule-2/index'),
            meta: { title: '课程与学生评教', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/rule-3',
            name: '课程与督导评教',
            component: () => import('@/views/rule/rule-3/index'),
            meta: { title: '课程与督导评教', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/rule-4',
            name: '学生与督导评教',
            component: () => import('@/views/rule/rule-4/index'),
            meta: { title: '学生与督导评教', icon: 'table', roles: [2, 3] }
          }
        ]
      },
      {
        path: 'major',
        name: '主成分分析',
        component: () => import('@/views/major/index'),
        meta: { title: '主成分分析', icon: 'table', roles: [2, 3] },
        children: [
          {
            path: '/major-2',
            name: '学生评教成绩',
            component: () => import('@/views/major/major-2/index'),
            meta: { title: '学生评教成绩', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/major-3',
            name: '督导评教成绩',
            component: () => import('@/views/major/major-3/index'),
            meta: { title: '督导评教成绩', icon: 'table', roles: [2, 3] }
          }
        ]
      },
      {
        path: 'cluster',
        name: '聚类分析',
        component: () => import('@/views/cluster/index'),
        meta: { title: '聚类分析', icon: 'table', roles: [2, 3] },
        children: [
          {
            path: '/cluster-1',
            name: '课程与学生评教',
            component: () => import('@/views/cluster/cluster-1/index'),
            meta: { title: '课程与学生评教', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/cluster-2',
            name: '课程与督导评教',
            component: () => import('@/views/cluster/cluster-2/index'),
            meta: { title: '课程与督导评教', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/cluster-3',
            name: '学生与督导评教',
            component: () => import('@/views/cluster/cluster-3/index'),
            meta: { title: '学生与督导评教', icon: 'table', roles: [2, 3] }
          }
        ]
      },
      {
        path: 'time',
        name: '时间序列分析',
        component: () => import('@/views/time/index'),
        meta: { title: '时间序列分析', icon: 'table', roles: [2, 3] },
        children: [
          {
            path: '/time-1',
            name: '学生评教时间',
            component: () => import('@/views/time/time-1/index'),
            meta: { title: '学生评教时间', icon: 'table', roles: [2, 3] }
          },
          {
            path: '/time-2',
            name: '督导评教时间',
            component: () => import('@/views/time/time-2/index'),
            meta: { title: '督导评教时间', icon: 'table', roles: [2, 3] }
          }
        ]
      }
    ]
  },
  // 学生端
  {
    path: '/student',
    component: Layout,
    redirect: '/student/ability-radar',
    meta: { title: '学生端', icon: 'user', roles: [1] },
    children: [
      {
        path: 'ability-radar',
        name: 'AbilityRadar',
        component: () => import('@/views/student/AbilityRadar/index.vue'),
        meta: { title: '能力雷达图', icon: 'radar-chart', roles: [1] }
      },
      {
        path: 'courses',
        name: 'StudentCourses',
        component: () => import('@/views/student/StudentCourses/index.vue'),
        meta: { title: '修读课程表', icon: 'table', roles: [1] }
      },
      {
        path: 'academic-warning',
        name: 'AcademicWarning',
        component: () => import('@/views/student/AcademicWarning/index.vue'),
        meta: { title: '学业预警', icon: 'warning', roles: [1] }
      }
    ]
  },
  // 教师端
  {
    path: '/teacher',
    component: Layout,
    redirect: '/teacher/ability-comparison',
    meta: { title: '教师端', icon: 'teacher', roles: [2] },
    children: [
      {
        path: 'ability-comparison',
        name: 'AbilityComparison',
        component: () => import('@/views/teacher/StudentAbilityCompare/index.vue'),
        meta: { title: '学生能力对比', icon: 'radar-chart', roles: [2] }
      },
      {
        path: 'warning',
        name: 'StudentWarning',
        component: () => import('@/views/teacher/StudentWarningList/index.vue'),
        meta: { title: '学业预警处理', icon: 'warning', roles: [2] }
      },
      {
        path: 'competition',
        name: 'CompetitionStatistics',
        component: () => import('@/views/teacher/CompetitionStatistics/index.vue'),
        meta: { title: '竞赛获奖统计', icon: 'medal', roles: [2] }
      },
      {
        path: 'score-trend',
        name: 'ScoreTrendAnalysis',
        component: () => import('@/views/teacher/ScoreTrendAnalysis/index.vue'),
        meta: { title: '成绩趋势分析', icon: 'chart-line', roles: [2] }
      }
    ]
  },
  // 专业课程体系管理
  {
    path: '/CurriculumManagement',
    component: Layout,
    redirect: '/CurriculumManagement/index.vue',
    meta: { title: '管理员端', icon: 'admin', roles: [3] },
    children: [
      {
        path: 'curriculum/import',
        name: 'CurriculumImport',
        component: () => import('@/views/CurriculumManagement/CurriculumImport/index.vue'),
        meta: { title: 'Excel导入', icon: 'document', roles: [3] }
      },
      {
        path: 'curriculum/generate',
        name: 'CurriculumGenerate',
        component: () => import('@/views/CurriculumManagement/CurriculumGenerate/index.vue'),
        meta: { title: '课程体系生成', icon: 'edit', roles: [3] }
      },
      {
        path: 'curriculum/adjust',
        name: 'CurriculumAdjust',
        component: () => import('@/views/CurriculumManagement/CurriculumAdjust/index.vue'),
        meta: { title: '课程体系微调', icon: 'edit', roles: [3] }
      },
      {
        path: 'curriculum/view',
        name: 'CurriculumView',
        component: () => import('@/views/CurriculumManagement/CurriculumView/index.vue'),
        meta: { title: '课程体系查看', icon: 'view', roles: [3] }
      }
    ]
  },
  // 学业导师与辅导员管理
  {
    path: '/TutorClassManagement',
    component: Layout,
    redirect: '/TutorClassManagement/index',
    meta: { title: '管理员端', icon: 'admin', roles: [3] },
    children: [
      {
        path: 'tutor-class',
        name: 'TutorClassManagement',
        component: () => import('@/views/TutorClassManagement/index.vue'),
        meta: { title: '导师-班级管理', icon: 'user', roles: [3] }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
